[Preview] MSAL and shared token cache support#9982
[Preview] MSAL and shared token cache support#9982cormacpayne wants to merge 22 commits intoAzure:Az.Accounts-previewfrom
Conversation
…emove this dependency)
tools/RepoTasks/RepoTasks.RemoteWorker/RepoTasks.RemoteWorker.csproj
Outdated
Show resolved
Hide resolved
src/Accounts/Authentication/Authentication/DelegatingAuthenticator.cs
Outdated
Show resolved
Hide resolved
| public ManagedServiceIdentityParameters( | ||
| IAzureEnvironment environment, | ||
| IAzureTokenCache tokenCache, | ||
| string tenantId, |
There was a problem hiding this comment.
Seems like this should contain parameters to contain identity type (SystemAssigned, ClientOrObjectId, ResourceId and identity id (string). These are all properties of IAzureAccount, but seems like we could use them to populate the account here.
There was a problem hiding this comment.
Also, MSISecret, and MSiEndpoint
|
|
||
| if (account.IsPropertySet(AppServiceManagedIdentityFlag)) | ||
| { | ||
| return new ManagedServiceAppServiceAccessToken(account, environment, GetFunctionsResourceId(resourceId, environment), tenant); |
There was a problem hiding this comment.
Would it be cleaner to have one authenticator for AppServiceMSI first in the chain, and the authenticator for Compute MSI after?
src/Accounts/Authentication/Authentication/Clients/AuthenticationClientFactory.cs
Show resolved
Hide resolved
| public const string AppServiceManagedIdentityFlag = "AppServiceManagedIdentityFlag"; | ||
|
|
||
| public const string CommonAdTenant = "Common", | ||
| public const string CommonAdTenant = "organizations", |
There was a problem hiding this comment.
Seems like we should have this constant in one place, and use it evwerywhere. Also, same question as before about whether thsi works with MSA
| } | ||
|
|
||
| DefaultContextKey = profile.DefaultContextKey ?? "Default"; | ||
| DefaultContextKey = profile.DefaultContextKey ?? (profile.Contexts.Any() ? null : "Default"); |
There was a problem hiding this comment.
Setting the defautl key to null if there are contexts but none selected - when would this occur?
There was a problem hiding this comment.
Needs validate: If logged in in VS (not PS), when first time runing PS command (not select-context), should be prompted with "please select a context"
| var accounts = authenticationClientFactory.ListAccounts(); | ||
| if (!accounts.Any()) | ||
| { | ||
| if (!Contexts.Any(c => c.Key != "Default" && c.Value.Account.Type == AzureAccount.AccountType.User)) |
There was a problem hiding this comment.
I think this method could use a bit of breaking up.
RemoveUserContexts()
RemoveUnmatchedUserContexts()
etc.
Also, as stated above, we need soem tracing here so we can tell why a context was removed if soemthign goes wrong.
src/Accounts/Authentication/Authentication/Clients/AuthenticationClientFactory.cs
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| return authenticator as IAuthenticatorBuilder; | ||
| }); | ||
| AppendAuthenticator(() => { return new InteractiveUserAuthenticator(); }); | ||
| var defaultBuilder = new DefaultAuthenticatorBuilder(); |
There was a problem hiding this comment.
Wouldn't that be 2 InteractiveUserAuthenticators 🤔 ?
to support IAzureMsalTokenCache
6c69f84 to
b941dca
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
44f6f2a to
fbcc1dc
Compare
a640cbf to
9c9c7c8
Compare
Description
Checklist
CONTRIBUTING.mdChangeLog.mdfile(s) has been updated:ChangeLog.mdfile can be found atsrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md## Upcoming Releaseheader -- no new version header should be added